package com.feicheng.controller;


import com.feicheng.base.result.Result;
import com.feicheng.model.OutboundHeaderWithItem;
import com.feicheng.model.OutboundWithSaleWithWarehouse;
import com.feicheng.service.ProviderWarehouseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hao.zhang
 * @since 2022-07-04
 */
@RestController("/outbound")
@RequestMapping("/outbound")
public class OutboundHeaderController {

    @Autowired
    ProviderWarehouseController providerWarehouseController;

    /**
     * 出库详情查询
     * @param outboundHeaderId 出库头Id
     * @param current 当前页
     * @param size 当前条数
     * @author jing.zhou
     * @return
     */
    @GetMapping("/detail/page")

    public Result outDetail(
             Integer outboundHeaderId,
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size
    ) {
        return providerWarehouseController.outDetail(outboundHeaderId,size,current);
    }

    /**
     * 出库列表条件分页查询
     * @param current 当前页
     * @param size 当前条数
     * @param outboundWithSaleWithWarehouse 出库信息
     * @author wei.zhang
     * @return
     */
    @GetMapping("/page")
    public Result getOutbound(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            OutboundWithSaleWithWarehouse outboundWithSaleWithWarehouse) {
        return providerWarehouseController.getOutbound(current, size, outboundWithSaleWithWarehouse);
    }

    /**
     * 新增出库接口
     * @param outboundHeaderWithItem 出库信息
     * @author siyu.liu
     * @return
     */
    @PostMapping("/info")
    public Result insertOutbound(@RequestBody OutboundHeaderWithItem outboundHeaderWithItem){
        return providerWarehouseController.insertOutbound(outboundHeaderWithItem);
    }

}

